﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using Zatify.Domain.Data;

namespace Zatify.WebUI.Models
{
    public class BusinessRegistrationStep1ViewModel
    {
        public Guid SecurityToken { get; set; }
        public Double TimeZoneOffset { get; set; }

        [Required(ErrorMessage = "User ID required")]
        [RegularExpression("^[a-zA-Z0-9]{6,16}$", ErrorMessage = "The user id must be 6-16 characters long and contain only alpha-numeric characters")]
        [Remote("BusinessUserIDUnique", "Registration", ErrorMessage = "User ID must be unique.")]
        public string UserID { get; set; }

        [Required(ErrorMessage = "Password required")]
        [RegularExpression("^[a-zA-Z0-9]{6,16}$", ErrorMessage = "The password must be 6-16 characters long and contain only alpha-numeric characters")]
        public string Password { get; set; }

        [Required(ErrorMessage = "Confirm Password required")]
        [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
        public string ConfirmPassword { get; set; }

        [Required(ErrorMessage = "Email required")]
        [RegularExpression(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", ErrorMessage = "Please enter a valid e-mail adress")]
        [StringLength(50, ErrorMessage = "Email cannot be longer than 50 characters.")]
        [Remote("BusinessEmailUnique", "Registration", ErrorMessage = "Email must be unique.")]
        public string Email { get; set; }

        [Required(ErrorMessage = "Business Name required")]
        [StringLength(100, ErrorMessage = "Business Name cannot be longer than 100 characters.")]
        public string BusinessName { get; set; }

        [StringLength(100, ErrorMessage = "Web cannot be longer than 100 characters.")]
        public string Web { get; set; }

        [Required(ErrorMessage = "Bussines Phone required")]
        [StringLength(50, ErrorMessage = "Bussines Phone cannot be longer than 50 characters.")]
        public string BusinessPhone { get; set; }

        [StringLength(50, ErrorMessage = "Bussines Cell Phone cannot be longer than 50 characters.")]
        public string CellPhone { get; set; }

        [StringLength(50, ErrorMessage = "Bussines Toll Free Phone cannot be longer than 50 characters.")]
        public string TollFreePhone { get; set; }

        [StringLength(50, ErrorMessage = "Bussines Fax cannot be longer than 50 characters.")]
        public string Fax { get; set; }

        [Required(ErrorMessage = "Street Address required")]
        [StringLength(100, ErrorMessage = "Street Address cannot be longer than 100 characters.")]
        public string StreetAddress1 { get; set; }

        [StringLength(100, ErrorMessage = "Street Address cannot be longer than 100 characters.")]
        public string StreetAddress2 { get; set; }

        [Required(ErrorMessage = "City required")]
        [StringLength(50, ErrorMessage = "City cannot be longer than 50 characters.")]
        public string City { get; set; }

        public string StateCode { get; set; }

        [Required(ErrorMessage = "Zip Code required")]
        [RegularExpression(@"^\d{5}(-\d{4})?$", ErrorMessage = " Zip Code must be 5 characters length")]
        public string ZipCode { get; set; }
    }

    public class BusinessRegistrationStep2ViewModel
    {
        [Required(ErrorMessage = "Description required")]
        public string Description { get; set; }

        public byte[] Picture { get; set; }
        public string PictureContentType { get; set; }

        [StringLength(100, ErrorMessage = "Referred By cannot be longer than 100 characters.")]
        public string ReferredBy { get; set; }

        #region BusinessHours

        public TimeSpan SunFrom { get; set; }
        public TimeSpan SunTo { get; set; }
        public bool SunClosed { get; set; }
        public bool Sun24HoursOpen { get; set; }

        public TimeSpan MonFrom { get; set; }
        public TimeSpan MonTo { get; set; }
        public bool MonClosed { get; set; }
        public bool Mon24HoursOpen { get; set; }

        public TimeSpan TueFrom { get; set; }
        public TimeSpan TueTo { get; set; }
        public bool TueClosed { get; set; }
        public bool Tue24HoursOpen { get; set; }

        public TimeSpan WedFrom { get; set; }
        public TimeSpan WedTo { get; set; }
        public bool WedClosed { get; set; }
        public bool Wed24HoursOpen { get; set; }

        public TimeSpan ThuFrom { get; set; }
        public TimeSpan ThuTo { get; set; }
        public bool ThuClosed { get; set; }
        public bool Thu24HoursOpen { get; set; }

        public TimeSpan FriFrom { get; set; }
        public TimeSpan FriTo { get; set; }
        public bool FriClosed { get; set; }
        public bool Fri24HoursOpen { get; set; }

        public TimeSpan SatFrom { get; set; }
        public TimeSpan SatTo { get; set; }
        public bool SatClosed { get; set; }
        public bool Sat24HoursOpen { get; set; }

        #endregion
    }

    public class BusinessRegistrationStep3CategoriesViewModel
    {
        public Category CurrentCategory { get; set; }
        public IList<Category> Categories { get; set; }
    }
    public class BusinessRegistrationStep3ViewModel
    {
        public String SelectegCategoriesIds { get; set; }

        public Boolean NewCategoryName1IsChecked { get; set; }
        [StringLength(250, ErrorMessage = "Category Name cannot be longer than 250 characters.")]
        public String NewCategoryName1 { get; set; }

        public Boolean NewCategoryName2IsChecked { get; set; }
        [StringLength(250, ErrorMessage = "Category Name cannot be longer than 250 characters.")]
        public String NewCategoryName2 { get; set; }

        public Boolean NewCategoryName3IsChecked { get; set; }
        [StringLength(250, ErrorMessage = "Category Name cannot be longer than 250 characters.")]
        public String NewCategoryName3 { get; set; }
    }

    public class BusinessRegistrationStep4ViewModel
    {
        public string StateCode { get; set; }
    }

    public class BusinessRegistrationStep5ViewModel
    {
        [Required(ErrorMessage = "Credit Card Number required")]
        [StringLength(20, ErrorMessage = "Credit Card Number cannot be longer than 20 characters.")]
        public string CreditCardNo { get; set; }

        [Required(ErrorMessage = "Credit Card Name required")]
        [StringLength(50, ErrorMessage = "Credit Card Name cannot be longer than 50 characters.")]
        public string CreditCardName { get; set; }

        [Required]
        [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd.MM.yyyy}")]
        public DateTime CreditCardExpDate { get; set; }

        public Int32 CreditCardExpirationMonth { get; set; }
        public Int32 CreditCardExpirationYear { get; set; }

        [Required(ErrorMessage = "Credit Card PIN required")]
        [StringLength(10, ErrorMessage = "Credit Card PIN cannot be longer than 10 characters.")]
        public string CreditCardPin { get; set; }

        [Required(ErrorMessage = "Street Address required")]
        [StringLength(100, ErrorMessage = "Billing Address cannot be longer than 100 characters.")]
        public string BillingAddress1 { get; set; }
        [StringLength(100, ErrorMessage = "Billing Address cannot be longer than 100 characters.")]
        public string BillingAddress2 { get; set; }

        [Required(ErrorMessage = "City required")]
        [StringLength(50, ErrorMessage = "City cannot be longer than 50 characters.")]
        public string BillingCity { get; set; }
        public string BillingStateCode { get; set; }

        [Required(ErrorMessage = "Zip required")]
        [RegularExpression(@"^\d{5}(-\d{4})?$", ErrorMessage = " Zip code must be 5 characters length")]
        public string BillingZipCode { get; set; }


        public bool BillingUse { get; set; }

        public string BusinessAddress1 { get; set; }
        public string BusinessAddress2 { get; set; }
        public string BusinessCity { get; set; }
        public string BusinessStateCode { get; set; }
        public string BusinessZipCode { get; set; }
    }
}